<?php 


	/**
	* 
	*/
	class BlockColumn
	{
		var list; #list of block.

		function __construct()
		{
			$this->list = array();
		}

		function __construct($input){
			if ($input instanceof BlockColumn) {
				$this->list = $input->list;
			}
		}

		public function getNumberOfBlock()
		{
			return sizeof($this->list);
		}

		public function getFirst()
		{
			if(sizeof($this->list) > 0)
				return reset($this->list);
			else
				return '0';
		}

		public function addBlock($block)
		{
			array_push($this->list, $block);
		}

		public function popBlock()
		{
			if(sizeof($this->list) > 0)
				return array_pop($this->list);
			return null;
		}

		public function print()
		{
			if(sizeof($this->list) > 0)
				echo join(' => ', $this->list) . '<br />';
		}

		public function compareWith($cCompare)
		{
			if ($cCompare instanceof BlockColumn) {
				if(sizeof($this->list) === sizeof($cCompare->list)){
					$l1 = reset($this->list);
					$l2 = reset($cCompare->list);
					if($l1 === $l2){
						for ($i=0; $i < sizeof($this->list); $i++) { 
							$l1 = next($this->list);
							$l2 = next($this->list);
							if($l1 !== $l2)
								return false;
						}
						return true;
					}
				}
			}
			return false;
		}

	}	


	/**
	* 
	*/
	class BlockWorld
	{
		var father;
		var columns;

		function __construct()
		{
			$this->father = null;
			$this->columns = array();
		}

		public function addCol($block)
		{
			$temp = new BlockColumn();
			$temp->addBlock($block);
			array_push($this->columns, $temp);
		}

		
	}


 ?>